Skip to content

feat: add PhoneService, PhoneAPIKeyService, and WebhookService#5

Merged
AchoArnold merged 3 commits intomainfrom
feature/add-phone-webhook-services
May 5, 2026
Merged

feat: add PhoneService, PhoneAPIKeyService, and WebhookService#5
AchoArnold merged 3 commits intomainfrom
feature/add-phone-webhook-services

Conversation

@AchoArnold
Copy link
Copy Markdown
Member

Adds three new services to the SDK for managing phones, phone API keys, and webhooks programmatically.

New Services

  • PhoneService: \Upsert()\ and \UpsertFCMToken()\ for phone management
  • PhoneAPIKeyService: \Store()\ for creating phone API keys
  • WebhookService: \Store()\ for creating webhooks with signing keys

Changes

  • \client.go: Register new services (Phones, PhoneAPIKeys, Webhooks)
  • \phone_service.go\ + \phone.go: Phone models and service
  • \phone_api_key_service.go\ + \phone_api_key.go: PhoneAPIKey models and service
  • \webhook_service.go\ + \webhook.go: Webhook models and service

These are needed by the httpSMS integration test suite to dynamically create phones and webhooks per test.

AchoArnold and others added 3 commits May 5, 2026 11:42
- PhoneService: Upsert() and UpsertFCMToken() for phone management
- PhoneAPIKeyService: Store() for creating phone API keys
- WebhookService: Store() for creating webhooks with signing keys
- Register new services on Client struct

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add success, error, and request verification tests for all new service
methods introduced in this branch:
- PhoneService.Upsert and PhoneService.UpsertFCMToken
- PhoneAPIKeyService.Store
- WebhookService.Store

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AchoArnold AchoArnold requested a review from Copilot May 5, 2026 19:55
@AchoArnold AchoArnold merged commit 40737b4 into main May 5, 2026
4 checks passed
@AchoArnold AchoArnold deleted the feature/add-phone-webhook-services branch May 5, 2026 19:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the Go SDK with new write-side services for provisioning phones, phone API keys, and webhooks, which fits the SDK’s role as a thin client over the httpSMS API and supports the integration tests’ need to create these resources programmatically.

Changes:

  • Registers Phones, PhoneAPIKeys, and Webhooks on the shared Client.
  • Adds models and service methods for phone upsert/FCM token binding, phone API key creation, and webhook creation.
  • Adds stub-backed unit tests for the new services and updates the google/uuid dependency version.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
client.go Wires the three new services into client construction.
phone.go Adds the phone resource model and response wrapper.
phone_service.go Adds phone upsert and FCM-token endpoints.
phone_service_test.go Adds success, error, and request-shape tests for phone APIs.
phone_api_key.go Adds the phone API key resource model and response wrapper.
phone_api_key_service.go Adds the phone API key creation endpoint.
phone_api_key_service_test.go Adds tests for phone API key creation behavior.
webhook.go Adds the webhook resource model and response wrapper.
webhook_service.go Adds the webhook creation endpoint.
webhook_service_test.go Adds tests for webhook creation behavior.
internal/stubs/phone.go Adds phone endpoint stub payloads.
internal/stubs/phone_api_key.go Adds phone API key stub payloads.
internal/stubs/webhook.go Adds webhook stub payloads.
go.mod Bumps github.com/google/uuid to v1.6.0.
go.sum Refreshes checksums for the dependency bump.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread phone_service.go
Comment on lines +14 to +19
PhoneNumber string `json:"phone_number"`
FcmToken string `json:"fcm_token,omitempty"`
MessagesPerMinute uint `json:"messages_per_minute,omitempty"`
MaxSendAttempts uint `json:"max_send_attempts,omitempty"`
MessageExpirationSeconds uint `json:"message_expiration_seconds,omitempty"`
SIM string `json:"sim,omitempty"`
Comment thread webhook_service.go
Comment on lines +20 to +22
// Store adds a new webhook
func (service *WebhookService) Store(ctx context.Context, params *WebhookStoreParams) (*WebhookResponse, *Response, error) {
request, err := service.client.newRequest(ctx, http.MethodPost, "/v1/webhooks", params)
Comment thread client.go
Comment on lines +28 to +30
Phones *PhoneService
PhoneAPIKeys *PhoneAPIKeyService
Webhooks *WebhookService
Comment thread phone_api_key_service.go

// Store adds a new phone api key
func (service *PhoneAPIKeyService) Store(ctx context.Context, params *PhoneAPIKeyStoreParams) (*PhoneAPIKeyResponse, *Response, error) {
request, err := service.client.newRequest(ctx, http.MethodPost, "/v1/phone-api-keys/", params)
@AchoArnold
Copy link
Copy Markdown
Member Author

All 4 review comments have been addressed in commits 0df3505 and d10459f on main:

  1. Pointer types for PhoneUpsertParams — Optional fields now use *string/*uint so callers can distinguish 'unset' from zero values.
  2. Webhook event constants — Tests and stubs updated to use EventTypeMessagePhoneReceived/EventTypeMessagePhoneSent instead of raw strings.
  3. README updated — Phones, Phone API Keys, and Webhooks added to the Implemented section.
  4. Trailing slash removed/v1/phone-api-keys//v1/phone-api-keys for consistency with other endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants